package com.codeoss.framework.view.service.impl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.codeoss.framework.context.YunContext;
import com.codeoss.framework.response.ImageResponse;
import com.codeoss.framework.service.IImageService;
import com.codeoss.framework.view.component.Component;
import com.codeoss.framework.view.component.Image;
import com.codeoss.framework.view.service.IVariableService;

@Service
public class ImageComponentService extends ComponentService{
	@Autowired
    private IVariableService variableService;
	@Autowired
	private IImageService imageService;
	@Override
	public void processValue(YunContext yunContext, Component component,Map<String,String> paraMap,Map<String,Object> dataMap) {
		// TODO Auto-generated method stub
		Image image=(Image)component;
		if(paraMap.containsKey(image.getId())) {
			String sValue=paraMap.get(image.getId());
			ImageResponse imageResponse=imageService.getImageByFilename(sValue);
			variableService.setVariableValue(yunContext, image.getVarName(), imageResponse.getContent());
		}
	}
}
